<template>
  <van-steps direction="vertical" :active="initProcessActive">
    <van-step v-if="submitpsn">
      <h3>【{{submitpsn.name}}】发起申请</h3>
      <p>{{submitpsn.create_time}}</p>
    </van-step>
    <van-step v-for="(item,index) of approvepsn" :key="index" v-if="approvepsn.length">
      <h3>【{{item.name}}】{{state[item.status||0].lable}} </h3>
      <p>{{item.create_time}}</p>
    </van-step>
  </van-steps>
</template>
<script>
import state from "./../js/state.js";
export default {
  props: {
    submitpsn: {
      // 提交人信息
      type: Object,
      default: () => {}
    },
    approvepsn: {
      // 审批人信息
      type: Array,
      default: () => []
    }
  },
  data() {
    return {
      state: state
    };
  },
  computed: {
    // 初始化当前进度
    initProcessActive() {
      if (!this.approvepsn || !this.approvepsn.length) {
        return 1;
      }
      let array = this.approvepsn;
      let value = 0;
      for (let index = 0; index < array.length; index++) {
        const element = array[index];
        if (element.status) {
          value = index;
        }
      }
      return value + 1;
    }
  }
};
</script>